<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/static/jquery-3.6.0.min.js}"></script>
</head>
<body>
********登录********<br/>
用户名:<input type="text" id="userName"><br/>
密码:<input type="password" id="password"><br/>
<button id="doLogin">登录</button><br/>
<a th:href="@{/register}">去注册。。。</a>
</body>
<script>
    $(document).ready(function(){
        $("#doLogin").click(function(){
            var userName = $("#userName").val()
            var password = $("#password").val()

            var data = {}
            data['userName'] = userName
            data['password'] = password

            $.ajax({
                type:'post',
                url:'/doLogin',
                data:JSON.stringify(data),
                dataType:'json',
                contentType:'application/json',
                success:function(res){
                    if(res){
                        window.location.href='/index'
                    }else{
                        console.log("登录失败...")
                    }
                }
            })

        })
    })
</script>
</html>
